/**
 * Created by Administrator on 2016/12/8 0008.
 */

$(function(){
    $("#qhTable thead tr th").css("text-align","center");
});

$(function () {
    init();
});

function init() {
    $("#qhTable").bootstrapTable({
        height: "900px",
        url: "data.json",
        onLoadSuccess:function(data){
            $("#qhTable .bs-checkbox").hide();
        }
    });
    $("#tplDIV").load("product.tpl.html");
    $(".columns button").height(20);
    $(".fixed-table-body").css({"height":"auto"});
    //$(".bs-checkbox").hide();
}

function myhide(){
    if($(".myhide a").text() == "隐藏条件"){
        $(".condition").css("display","none");
        $(".myhide a").text("筛选");
        $(".myhide i").removeClass("icon-double-angle-up");
        $(".myhide i").addClass("icon-double-angle-down");
    }else {
        $(".condition").css("display","block");
        $(".myhide a").text("隐藏条件");
        $(".myhide i").removeClass("icon-double-angle-down");
        $(".myhide i").addClass("icon-double-angle-up");
    }
}
function responseHandler(res) {
    var needData = {
        rows: res.data.shoppingOrderItemList,
        total: res.total
    };
    return needData;
}

function operate(obj){
    if(obj.value=="批量操作")
    {
        obj.value="取消操作";
        $(".bs-checkbox").show();
        $("#qhTable").bootstrapTable("resetView");
        $(".fixed-table-container").append("<div id='btn-groups'>\
        <input type='button' class='btn btn-success' value='启用'>\
        <input type='button' class='btn btn-info' value='停用'>\
        <input type='button' class='btn btn-warning' value='打印'>\
        <input type='button' class='btn btn-danger' value='删除'>\
        <input type='button' class='btn btn-primary' value='下载'>\
        </div>")
    }
    else
    {
        obj.value="批量操作";
        $(".bs-checkbox").hide();
        $("#qhTable").bootstrapTable("resetView");
        $("#btn-groups").remove();
    }
}
//查询按钮
$("#query").on("click", function () {
    var message = {};
    $(".condition [data-name]").each(function (i, element) {
        message[$(element).attr('data-name')] = $(element).val();
    });
    $('.radio').children('label').children('input').each(function(i,ipt){
        if($(ipt).prop('checked')){
            message.isValid=$(ipt).val();
        }
    });
    // $.ajax({
    //     type:"post",
    //     url:"http://192.168.59.104:8081/shixiaobao/console/addPersonalUserInfo",
    //     data:message
    // });
    console.log(message);

});
//清除按钮
$("#clear").on("click",function () {
    $(".condition [data-name]").each(function (i, element){
        if ($(element).attr('data-name') == 'userType'){
            $(".kinds-ser").val("建筑工人");
        }else{
            $(element).val("");
        }
    });
});


